<fieldset class="cbi-section">
	<legend><%:Running Status%></legend>
	<fieldset class="cbi-section">
		<div class="cbi-value">
			<label class="cbi-value-title">Nginx <%:Status%></label>
			<div class="cbi-value-field" id="_nginx_status"><%:Collecting data...%></div>
		</div>
		<div class="cbi-value">
			<label class="cbi-value-title"></label>
			<div class="cbi-value-field">
				<font color="red" id="tips"></font>
				<ul id="tips2">
					<li>rtmp rtmp://ip/live/<%:Stream name%></li>
					<li>http(s)-flv http(s)://ip/flv/<%:Stream name%></li>
					<li>hls http(s)://ip/hls/<%:Stream name%>.m3u8</li>
					<li>hls+ http(s)://ip/hls2/<%:Stream name%>.m3u8</li>
					<li>http(s)-ts http(s)://ip/ts/<%:Stream name%></li>
				</ul>
			</div>
		</div>
	</fieldset>
</fieldset>

<script type="text/javascript">//<![CDATA[
	var nginx_status = document.getElementById('_nginx_status');
	XHR.poll(3, '<%=url([[admin]], [[nas]], [[pingos]], [[status]])%>', null,
		function(x, json) {
			if (x && x.status == 200) {
				if (nginx_status) {
					var str = "";
					if (json.status) {
						document.getElementById("tips").innerHTML = '<%:If you need external network access, please open the port by yourself.%>';
						str = '<font color="green"><%:RUNNING%> ✓</font><input type="button" class="cbi-button cbi-input-apply" value="<%:Enter interface%>" onclick="open_web()" />'
					} else {
						document.getElementById("tips").innerHTML = '';
						str = '<font color="red"><%:NOT RUNNING%> X</font>';
					}
					nginx_status.innerHTML = str;
				}
			}
		}
	);
	function open_web(){
		var port = '<%=luci.sys.exec("uci -q get pingos.@global[0].http_port"):gsub("^%s*(.-)%s*$", "%1")%>';
		var ishttps = '<%=luci.sys.exec("uci -q get pingos.@global[0].https"):gsub("^%s*(.-)%s*$", "%1")%>';
		var protocol = (ishttps == "1") ? "https://" : "http://";
		var hostname = location.hostname;
		
		var url = protocol + hostname + ":" + port;
		window.open(url, 'target', '');
	}
//]]></script>